﻿using System;

namespace Shell.PocoDot.Attributes
{
    /// <summary>
    /// 用于标识一个 PocoDot 个另一个 PocoDot 之间的关系
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
    public class RelationAttribute : Attribute
    {
        /// <summary>
        /// 构建一个新的实例
        /// </summary>
        /// <param name="relatedTo">指定的关系中的另一端 PocoDot 的类型</param>
        /// <param name="relationship">从当前 PocoDot 到另一端的 PocoDot 之间的映射关系</param>
        /// <param name="reversedRelationship">从另一端的 PocoDot 到当前 PocoDot 之间的映射关系</param>
        public RelationAttribute(Type relatedTo, Relationships relationship, Relationships reversedRelationship)
        {
            this.RelatedTo = relatedTo;
            this.Relationship = relationship;
            this.ReversedRelationship = reversedRelationship;
        }

        /// <summary>
        /// 获取或设置指定的关系中的另一端 PocoDot 的类型
        /// </summary>
        public Type RelatedTo { get; private set; }

        /// <summary>
        /// 获取或设置从当前 PocoDot 到另一端的 PocoDot 之间的映射关系
        /// </summary>
        public Relationships Relationship { get; private set; }

        /// <summary>
        /// 获取或设置从另一端的 PocoDot 到当前 PocoDot 之间的映射关系
        /// </summary>
        public Relationships ReversedRelationship { get; private set; }
    }
}
